package com.example.online_exam_system.service.impl;

import com.example.online_exam_system.dao.TestPageDao;
import com.example.online_exam_system.entity.Exam;
import com.example.online_exam_system.entity.TestPage;
import com.example.online_exam_system.service.TestPageService;
import org.apache.catalina.User;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;


/**
 * (TestPage)表服务实现类
 *
 * @author lianglong@asiainfo.com
 * @since 2021-11-25 13:58:41
 */
@Service("testPageService")
public class TestPageServiceImpl implements TestPageService {
    @Resource
    private TestPageDao testPageDao;

    /**
     * 通过ID查询单条数据
     *
     * @param testname 主键
     * @return 实例对象
     */
    @Override
    public TestPage queryById(Object testname) {
        return this.testPageDao.queryById(testname);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<TestPage> queryAllByLimit(int offset, int limit) {
        return this.testPageDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param testPage 实例对象
     * @return 实例对象
     */
    @Override
    public TestPage insert(TestPage testPage) {
        this.testPageDao.insert(testPage);
        return testPage;
    }

    /**
     * 修改数据
     *
     * @param testPage 实例对象
     * @return 实例对象
     */
    @Override
    public TestPage update(TestPage testPage) {
        this.testPageDao.update(testPage);
        return this.queryById(testPage.getTestname());
    }

    /**
     * 通过主键删除数据
     *
     * @param testname 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Object testname) {
        return this.testPageDao.deleteById(testname) > 0;
    }

    @Override
    public int insertTestPage(TestPage testPage) {
        return testPageDao.insertTestPage(testPage);
    }

    @Override
    public List<Map<String,Object>> queryExam() {
        return testPageDao.queryExam();
    }

    @Override
    public List<Map<String, Object>> getExamInfo(Map<String, Object> inParam) {
        return testPageDao.getExamInfo(inParam);
    }

    @Override
    public List<Map<String, Object>> getPageDetail(String testId) {
        return testPageDao.getPageDetail(testId);
    }
}
